/*
 Copyright 2009 Abdulla Abdurakhmanov (abdulla@latestbit.com)
 Original sources are available at www.latestbit.com

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.

 */

#ifndef URI_HPP
#define URI_HPP

#include "smartobjects/SmartObjectsDefs.hpp"

namespace smartobjects {
	/**
	 * Represents a Uniform Resource Identifier (URI) reference
	 *
	 * URI = [scheme:][//authority][path][?query][#fragment]
	 * Authority = [user-info@]host[:port]
	 */
	class URI : public virtual RefObject {
	public:
		SO_DLLPRFX URI(void);
		SO_DLLPRFX URI(const std::string&);
		SO_DLLPRFX virtual ~URI(void);

		SO_DLLPRFX void setScheme(const std::string&);
		SO_DLLPRFX const std::string& getScheme(void) const;

		SO_DLLPRFX void setUserInfo(const std::string&);
		SO_DLLPRFX const std::string& getUserInfo(void) const;

		SO_DLLPRFX void setHost(const std::string&);
		SO_DLLPRFX const std::string& getHost(void) const;

		SO_DLLPRFX void setPort(const unsigned);
		SO_DLLPRFX const unsigned getPort(void) const;

		SO_DLLPRFX void setPath(const std::string&);
		SO_DLLPRFX const std::string& getPath(void) const;

		SO_DLLPRFX void setQuery(const std::string&);
		SO_DLLPRFX const std::string& getQuery(void) const;

		SO_DLLPRFX void setFragment(const std::string&);
		SO_DLLPRFX const std::string& getFragment(void) const;

		/**
		 * String represantion of URI
		 */
		SO_DLLPRFX void setURIStr(const std::string&);
		SO_DLLPRFX const std::string& getURIStr() const;

	protected:
		SO_DLLPRFX void parseURI(void);
		SO_DLLPRFX void clearURI(void);
		SO_DLLPRFX void createURIStr();


	private:
		std::string m_sURI;

		std::string m_sScheme;
		std::string m_sUserInfo;
		std::string m_sHost;
		unsigned int m_nPort;
		std::string m_sPath;
		std::string m_sQuery;
		std::string m_sFragment;
	};
}

#endif // ENDPOINTURI_HPP
